<template>
	<view class="tab-container">
		<!-- 导航按钮 -->
		<view class="tab-nav">
			<view v-for="(item, index) in tabList" :key="index" class="tab-button"
				:class="[currentIndex === index ? 'active' : '']" @tap="handleSwitch(index)">
				{{item.id}}
			</view>
		</view>

		<!-- 滑动内容区域 -->
		<swiper class="tab-content" :current="currentIndex" @change="swiperChange" :duration="300"
			:disable-touch="false">
			<swiper-item v-for="(item, index) in tabList" :key="index">
				<view class="content-item">
					<image src="../../../static/blind/k1.png" mode="aspectFit" class="content-image" :lazy-load="true" />
				</view>
			</swiper-item>
		</swiper>
		<view class="content-left">
			
		</view>
		<view class="content-right">
			<view>
				<image src="../../../static/blind/kxjs.png" class="right-kx"></image>
			</view>
			<view>
				<image src="../../../static/blind/ljdh.png" class="right-lj"></image>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				currentIndex: 0,
				tabList: [{
						image: '../../../static/k2.png',
						id: "通1"
					},
					{
						image: '../../../static/k2.png',
						id: "通2"
					},
					{
						image: '../../../static/k3.png',
						id: "通3"
					},
					{
						image: '../../../static/k4.png',
						id: "通4"
					},
					{
						image: '../../../static/k5.png',
						id: "通5"
					},
					{
						image: '../../../static/k6.png',
						id: "通6"
					},
					{
						image: '../../../static/k7.png',
						id: "通7"
					}
				]
			}
		},
		methods: {
			handleSwitch(index) {
				if (this.currentIndex === index) return
				this.currentIndex = index
			},
			swiperChange(e) {
				this.currentIndex = e.detail.current
			}
		}
	}
</script>

<style lang="scss" scoped>
	/* 使用rpx适配多端 */
	$active-color: #644ddd;

	.tab-container {
		padding: 30rpx;
		position: relative;
	}

	.tab-nav {
		display: flex;
		width: 84%;
		margin: 0 auto;
		border-radius: 20px;
		justify-content: center;
		margin-bottom: 40rpx;
		border: 1px solid #644ddd;
		// gap: 20rpx;
	}

	.tab-button {
		width: 45px;
		height: 28px;
		border-radius: 30px;
		// background-color: #F0F0F0;
		transition: all 0.3s ease;
		color: #fff;
		text-align: center;
		font-size: 15px;
		line-height: 28px;

		&.active {
			background-color: $active-color;
			transform: scale(1.1);
		}
	}

	.tab-content {
		height: 800rpx;
		overflow: hidden;
		border-radius: 24rpx;
	}

	.content-item {
		width: 100%;
		height: 100%;
		display: flex;
		justify-content: center;
		align-items: center;
		// background-color: #f8f8f8;
	}

	.content-image {
		max-width: 100%;
		max-height: 100%;
		transition: opacity 0.3s;
		position: relative;
		top: -45px;
		// left: 10px;

		&.loaded {
			opacity: 1;
		}
	}
	// .content-left{
	// 	position: absolute;
	// 	left: 5px;
	// 	top: 20px;
	// 	image{
	// 		width: 50px;
	// 		height: 300px;
	// 	}
	// }
	.content-right{
		position: absolute;
		top: 120px;
		right: 10px;
		
		.right-kx{
			width: 55px;
			height: 55px;
		}
		.right-lj{
			margin-top: 10px;
			width: 55px;
			height: 55px;
		}
	}
</style>